package ManageGameHServer.bean;

import ManageGameHServer.classFile.NoDBConnectO;
import org.json.JSONObject;
import redis.clients.jedis.Jedis;

import java.util.Date;

/**
 * Created by Administrator on 2017/4/25.
 */
public class BaseBean {

    private static final long serialVersionUID = 1L;

    public static final String DEL_FLAG_NORMAL = "0";
    public static final String DEL_FLAG_DELETE = "1";
    public static final String DEL_FLAG_AUDIT = "2";

    public String id;
    public String del_flag = DEL_FLAG_NORMAL;
    public String create_by;
    public String create_time;
    public String update_by;
    public String update_time;


    public BaseBean(){
    }
    public BaseBean(String id){
        this();
        this.id = id;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }

    public String getDel_flag() {
        return del_flag;
    }
    public void setDel_flag(String del_flag) {
        this.del_flag = del_flag;
    }


    public String getCreate_by() {
        return create_by;
    }
    public void setCreate_by(String session) {
        Jedis loginJedis= NoDBConnectO.getCon();
        JSONObject jsonObject = new JSONObject(loginJedis.get(session));
        JSONObject userObj = (JSONObject)jsonObject.get("userObj");
        String userid = userObj.get("userId").toString();
        this.create_by = userid;
        this.update_by = userid;
    }

    public String getUpdate_by() {
        return update_by;
    }
    public void setUpdate_by(String session) {
        Jedis loginJedis= NoDBConnectO.getCon();
        JSONObject jsonObject = new JSONObject(loginJedis.get(session));
        JSONObject userObj = (JSONObject)jsonObject.get("userObj");
        String userid = userObj.get("userId").toString();
        this.update_by = userid;
    }

    public String getCreate_time() {
        return create_time;
    }
    public void setCreate_time(String create_time){
        if(create_time == null || "".equalsIgnoreCase(create_time.trim())
                || "null".equalsIgnoreCase(create_time)){
            create_time = Long.toString(System.currentTimeMillis());
        }
        this.create_time = create_time;
        this.update_time = create_time;
    }

    public String getUpdate_time() {
        return update_time;
    }
    public void setUpdate_time(String update_time) {
        if(update_time ==null || "".equalsIgnoreCase(update_time.trim())||
                "null".equalsIgnoreCase(update_time.trim())){
            update_time = Long.toString(System.currentTimeMillis());
        }
        this.update_time = update_time;
    }
}
